local f = 0
local u = 0

while turtle.forward() do
	f = f + 1
end

while true do
	local exist, data = turtle.inspect()

	if not exist or data.name == "minecraft:iron_bars" then
		turtle.up()
		u = u + 1
		break
	end

	turtle.up()
	u = u + 1
end

while not turtle.attack() do
	turtle.dig()
	turtle.forward()
	f = f + 1
end

while f > 0 do
	turtle.back()
	f = f - 1
end

while u > 0 do
	turtle.down()
	u = u - 1
end
